var app = getApp(),
  a = app.requirejs("core");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:[],
    show:true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log("options",options)
    if (!options.id || !options.type) {
      a.jump('', 5);
    }
    a.setting();
    this.setData(options);
    this.getList();
  },
  getList:function(){
      var that=this,
      id=that.data.id,
      type=that.data.type;
    a.get('order/RefundList',{
      order_id:id,
      type:type,
      uid: getApp().getCache("userinfo").uid
    },function(t){
      console.log("refund",t);
        if(t.code==0){
          that.setData({
            list:t.info,
            show:true
          })
        }else{
          a.alert(t.msg);
        }
    },true)

  },

  // 取消退款
  cancelRefund: function(){
    var that = this,
        order_id = that.data.list[0].order_id,
        user_id = that.data.list[0].uid;

    wx.showModal({
      title: '提示',
      content: '确定取消吗？',
      success: function (res) {
        if (res.confirm) {
          a.get('order/CancelRefundorder',{
            order_id: order_id,
            buyer_id: user_id,
            type: that.data.type
          },function(t){
            if (t.code == 0) {
              a.success("取消成功");

              setTimeout(function () {
                wx.navigateBack()
              }, 500)

            } else {
              a.alert(t.msg);
            }
          })
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  }
})